// WaitCommand.java
package org.zjx.command.basic;

import lombok.extern.slf4j.Slf4j;
import org.zjx.command.Command;
import org.zjx.core.IWindow;

@Slf4j
public class DelayCommand extends Command {
    private final long delay;

    public DelayCommand(IWindow window, long delay) {
        super(window, false,null);
        this.delay = delay;
    }

    @Override
    protected void doExecute() throws Exception {
        if (delay <= 0) return;
        long start = System.currentTimeMillis();
        while (System.currentTimeMillis() - start < delay) {
            checkInterruption();
            Thread.sleep(Math.min(100, delay - (System.currentTimeMillis() - start)));
        }
    }
}